import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.beans.BeanUtils;

/**
 * @author MI
 * @version 1.0
 * @date 2020/12/19 15:36
 */
public class Demo {
    public static void main(String[] args) {
        final Parent parent = new Parent("parent#son");
        final Son son = new Son();

        BeanUtils.copyProperties(parent, son);
        System.out.println(son);
    }

    static class Parent {
        private String str;

        public Parent() {
        }

        public Parent(String str) {
            this.str = str;
        }

        public String getStr() {
            return str;
        }

        public void setStr(String str) {
            this.str = str;
        }
    }

    static class Son extends Parent {
        private String name;

        {
            System.out.println("son代码块");
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            System.out.println("setName");
            this.name = name;
        }

        @Override
        public void setStr(String str) {
            super.setStr(str);
            System.out.println("super.setStr(str);");
            this.name = str.split("#")[1];
        }

        @Override
        public String toString() {
            System.out.println(ToStringBuilder.reflectionToString(this));
            return "Son{}";
        }
    }

}



